<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%>
<html>
<body class="easyui-layout list_body">
	<form id="menuForm" name="menuForm">
		<div class="list_body_north" data-options="region:'north'" border="false">
			<!-- 查询表单 -->
			<div style="padding: 3px" class="easyui-panel datagrid-toolbar">
				<div>
					<span>清算开始日期:</span>
					<input type="text" id="stl_dt_start" value="${yestedayDate}" name="stl_dt_start" class="easyui-datebox" data-options="editable:false"/>
					<span>清算结束日期:</span>
					<input type="text" id="stl_dt_end" value="${yestedayDate}" name="stl_dt_end" class="easyui-datebox" data-options="editable:false"/>
					<span>会员编号:</span>
					<input type="text" id="custom_no" name="custom_no" class="easyui-textbox" /> 
					<span>会员名称:</span> 
					<input type="text" id="custom_name" name="custom_name" class="easyui-textbox" /> 
					<br/>
					<span>手机号:</span>
					<input type="text" id="custom_phone" name="custom_phone" class="easyui-textbox" /> 
					<span>机构号:</span>
					<input type="text" id="ins_cd" name="ins_cd" class="easyui-textbox" /> 
					<span>机构名称:</span>
					<input type="text" id="ins_name" name="ins_name" class="easyui-textbox" /> 
					<a href="#" class="easyui-linkbutton btn" iconCls="icon-search" onclick="doSearch()">查询</a> 
					<a href="#" class="easyui-linkbutton btn" iconCls="icon-reload" onclick="resetForm()">重置</a>
				</div>
			</div>
			<!-- 维护汇总数据 -->
			<div style="padding: 3px" class="easyui-panel datagrid-toolbar">
				作为间接推荐人获利汇总：<span id="indirect_comm"></span>
				作为直接推荐人获利汇总：<span id="direct_comm"></span>
				作为当前会员获利汇总：<span id="cur_comm"></span>
			</div>
			<jiepos:buttonOperateTag menuCode="${menuCode }"></jiepos:buttonOperateTag>
		</div>
		<div data-options="region:'center'" border="false" class="list_body_center">
			<!-- 表格 -->
			<table id="menuTableId" fit="true"></table>
		</div>
	</form>
</body>
<script type="text/javascript">
	var grid;
	$(function() {
		getTotalInfo();
		/*加载表格数据*/
		grid = $("#menuTableId").jpgrid({
			url : "getLogCustomCommProfitSumListJson.do",
			baseColumns: false,
			columns : [ {
				title : "清算日期",
				field : "STL_DT",
				align : 'center'
			}, {
				title : "会员编号",
				field : "CUSTOM_NO",
				align : 'center'
			}, {
				title : "会员名称",
				field : "CUSTOM_NAME",
				align : 'center'
			}, {
				title : "所属机构",
				field : "INS_NM",
				align : 'center'
			}, {
				title : "业务名称",
				field : "SERVICE_NAME",
				align : 'center'
			}, {
				title : "业务参数名称",
				field : "SERVICE_PARAM_NAME",
				align : 'center'
			}, {
				title : "作为间接推荐人获利金额",
				field : "INDIRECT_COMM",
				align : 'center'
			}, {
				title : "作为直接推荐人获利金额",
				field : "DIRECT_COMM",
				align : 'center'
			}, {
				title : "当前会员获利金额",
				field : "CUR_COMM",
				align : 'center'
			}]
		});
	});

	function doSearch() {
		grid.load({
			stl_dt_start : $('#stl_dt_start').val(),
			stl_dt_end : $('#stl_dt_end').val(),
			custom_no : $('#custom_no').val(),
			custom_name : $('#custom_name').val(),
			custom_phone : $('#custom_phone').val(),
			ins_cd : $('#ins_cd').val(),
			ins_name : $('#ins_name').val()
		});
		getTotalInfo();
	}
	
	function exportFile(url){
		var checkedItems = $('#menuTableId').datagrid('getChecked');
		if(!checkedItems){
			return false;
		};
		commonFileDownload(url, "menuForm");
	}

	function getTotalInfo(){
		var data = {
				stl_dt_start : $('#stl_dt_start').val(),
				stl_dt_end : $('#stl_dt_end').val(),
				custom_no : $('#custom_no').val(),
				custom_name : $('#custom_name').val(),
				custom_phone : $('#custom_phone').val(),
				ins_cd : $('#ins_cd').val(),
				ins_name : $('#ins_name').val()
		};
		$.ajax({
			url : '../logCustomCommProfitSum/getLogCustomCommProfitTotal.do',
			data : data,
			success : function(result) {
				$("#all_cnt").html(result.ALL_CNT);
				$("#sum_amt").html(result.SUM_AMT);
				$("#sum_costfee").html(result.SUM_COSTFEE);
				$("#sum_midfee").html(result.SUM_MIDFEE);
				$("#indirect_comm").html(result.INDIRECT_COMM);
				$("#direct_comm").html(result.DIRECT_COMM);
				$("#cur_comm").html(result.CUR_COMM);
			}
		});
	}
</script>
</html>
